package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yami.shop.bean.model.PostLikeRecord;
import com.yami.shop.dao.PostLikeRecordMapper;
import com.yami.shop.service.PostLikeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 动态喜欢记录 服务实现类
 * </p>
 *
 * @author chajiu
 * @since 2021-06-29
 */
@Service
public class PostLikeRecordServiceImpl extends ServiceImpl<PostLikeRecordMapper, PostLikeRecord> implements PostLikeRecordService {

    @Override
    public boolean isLiked(String uid, String postId) {
        int count = count(Wrappers.lambdaQuery(new PostLikeRecord())
                .eq(PostLikeRecord::getUserId, uid)
                .eq(PostLikeRecord::getPostId, postId));
        return count > 0?true:false;
    }
}
